import pymysql


class DBManager:
    def __init__(self, host, user, password, database) -> None:
        self.connection = pymysql.connect(
            host=host, user=user, password=password, database=database, autocommit=True
        )

    def execute(self, sql):
        cursor = self.connection.cursor()
        cursor.execute(sql)
        result = cursor.fetchall()
        cursor.close()
        return result

    def close(self):
        self.connection.close()


